#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    cout << "Vvedite posledovatelnost" << endl;
    cin >> s;
    string s_1;
    char a;

    for (int i = 0; i < s.length(); i++) {
        a = s[i];
        if ((a == '(') || (a == '{') || (a == '[') || (a == '<') || s_1 == "")
                s_1 += a;
        else {
            if (s_1 != "") {
            if (((a == ')') && (s_1[s_1.length()-1] == '(')) || ((a == '}') && (s_1[s_1.length()-1] == '{')) || ((a == ']') && (s_1[s_1.length()-1] == '[')) || ((a == '>') && (s_1[s_1.length()-1]  == '<')))
                s_1.pop_back();
            }
       }
    }

    if (s_1 == "") {
        cout << "Yes";
    }
    else {
      cout << "No";
    }
    return 0;
}

